package com.itheima.dao;

import com.itheima.domain.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 注解方法开启二级缓存
 */
@CacheNamespace(blocking = true)
public interface UserAnnotationDao {


    @Select("select * from user")
    List<User> findAll();


    @Insert("insert into user (username, birthday, sex, address) values (#{username}, #{birthday}, #{sex}, #{address})")
    int saveUser(User user);


    @Update("update user set username=#{username}, birthday=#{birthday}, sex=#{sex}, address=#{address} where id=#{id}")
    int updateUser(User user);


    @Delete("delete from user where id = #{userId}")
    int deleteUser(int userId);


    @Select("select * from user where username like #{username}")
    List<User> findByName(String username);


    @Select("select count(*) from user")
    int findByTotal();


    @Select("select * from user where id = #{id}")
    User findById(int id);
}
